package com.techfengs.chapter04;

public class LogicOperatorExercise01 {
  public static void main(String[] args) {
    // 练习题1
    // 1
    int x = 5;
    int y = 5;
    if (x++ == 6 & ++y == 6) {
      x = 11;
    }
    System.out.println("x = " + x + ", y = " + y);

    // 2
    x = 5;
    y = 5;
    if (x++ == 6 && ++y == 6) {
      x = 11;
    }
    System.out.println("x = " + x + ", y = " + y);

    // 3
    x = 5;
    y = 5;
    if (x++ == 5 | ++y == 5) {
      x = 11;
    }
    System.out.println("x = " + x + ", y = " + y);

    // 4
    x = 5;
    y = 5;
    if (x++ == 5 || ++y == 5) {
      x = 11;
    }
    System.out.println("x = " + x + ", y = " + y);

    // 测试赋值语句的真假
    boolean xx = true;
    boolean yy = false;
    short z = 46;
    if ((z++ == 46) && (yy = true)) {
      z++;
    }
    if ((xx = false) || (++z == 49)) {
      z++;
    }
    System.out.println("z = " + z);
  }
}
